<?php
/**
 * 后台基类控制器
 */
namespace backend\component;

use backend\filter\RequestFilter;
use common\component\BaseController;
use common\component\Constant;

class BackendBaseController extends BaseController
{

    public $enableCsrfValidation = false;
    public $allowLog = true;
    /**
     * 应用端
     * @var string
     */
    public $appEnd = Constant::END_BACK;
    /**
     * 不需要权限验证的方法
     * @var array
     */
    public $exceptAction = [];
    /**
     * 排除不需要权限验证的URL
     * @var array
     */
    public $exceptUrl = [];

    public function actions()
    {
        return [
            'editor' => [
                'class' => 'common\actions\UEditorActionI',
                'config' => [
                    'imageUrlPrefix' => \Yii::$app->params["attach.image.url"],
                    'imagePathFormat' =>  \Yii::$app->params["attach.image.format"],
                ]
            ],
        ];
    }

    public function init()
    {
        $this->exceptUrl = \Yii::$app->params['exceptUrl'];
    }

    public function behaviors()
    {
        return [
            [
                'class' => 'backend\filter\LoginFilter',
                'except' => $this->exceptAction,
                'exceptUrl' => $this->exceptUrl,
                'errorMsg' => "无权限访问",
            ],
            //过滤请求参数
            /*[
                'class' => RequestFilter::className(),
            ]*/
        ];
    }

}